package com.smarthealthring.mm.api;

import com.smarthealthring.mm.bean.GetVerifyRes;
import com.smarthealthring.mm.bean.HrDetailRes;
import com.smarthealthring.mm.bean.LoginRes;
import com.smarthealthring.mm.bean.ModifyPwdRes;
import com.smarthealthring.mm.bean.RegistRes;
import com.smarthealthring.mm.bean.SleepDetailRes;
import com.smarthealthring.mm.bean.StepDetailRes;
import com.smarthealthring.mm.bean.SyncDataRes;
import com.smarthealthring.mm.bean.UpdateInfoRes;
import com.smarthealthring.mm.bean.WechatLoginRes;
import com.smarthealthring.mm.net.NetworkManager;
import com.smarthealthring.mm.utils.RxUtil;

import java.util.Map;

import io.reactivex.Flowable;
import retrofit2.http.QueryMap;

/**
 * Created by hewei26 on 2017/6/14.
 */

public class ApiRequest {

    //发送短信获取验证码
    public static Flowable<GetVerifyRes> getVerifyCode(Map<String, String> params) {
        return NetworkManager.getCommonClient()
                .create(ApiService.class)
                .getVerifyCode(params)
                .compose(RxUtil.scheduleTnansform())
                .compose(RxUtil.handleResult());
    }

    //通过验证码注册
    public static Flowable<RegistRes> regist(Map<String, String> params) {
        return NetworkManager.getCommonClient()
                .create(ApiService.class)
                .regist(params)
                .compose(RxUtil.scheduleTnansform())
                .compose(RxUtil.handleResult());
    }

    //登录
    public static Flowable<LoginRes> login(Map<String, String> params) {
        return NetworkManager.getCommonClient()
                .create(ApiService.class)
                .login(params)
                .compose(RxUtil.scheduleTnansform())
                .compose(RxUtil.handleResult());
    }

    //发送短信获取验证码
    public static Flowable<ModifyPwdRes> modifyPwd(Map<String, String> params) {
        return NetworkManager.getCommonClient()
                .create(ApiService.class)
                .modifyPwd(params)
                .compose(RxUtil.scheduleTnansform())
                .compose(RxUtil.handleResult());
    }

    //更新个人信息
    public static Flowable<UpdateInfoRes> updateInfo(Map<String, String> params) {
        return NetworkManager.getCommonClient()
                .create(ApiService.class)
                .updateInfo(params)
                .compose(RxUtil.scheduleTnansform())
                .compose(RxUtil.handleResult());
    }

    //同步数据
    public static Flowable<SyncDataRes> syncData(Map<String, String> params) {
        return NetworkManager.getCommonClient()
                .create(ApiService.class)
                .syncData(params)
                .compose(RxUtil.scheduleTnansform())
                .compose(RxUtil.handleResult());
    }

//    //微信登录
//    public static Flowable<WechatLoginRes> wechatLogin(Map<String, String> params) {
//        return NetworkManager.getWechatClient()
//                .create(ApiService.class)
//                .wechatLogin(params)
//                .compose(RxUtil.scheduleTnansform());
//    }
//
//
//    //微信个人信息
//    public static Flowable<Object> wechatUserInfo(Map<String, String> params) {
//        return NetworkManager.getWechatClient()
//                .create(ApiService.class)
//                .wechatUserInfo(params)
//                .compose(RxUtil.scheduleTnansform());
//    }

    //微信登录
    public static Flowable<Object> wechatLogin(Map<String, String> params) {
        return NetworkManager.getCommonClient()
                .create(ApiService.class)
                .wechatLogin(params)
                .compose(RxUtil.scheduleTnansform())
                .compose(RxUtil.handleResult());
    }

    //注销登录
    public static Flowable<Object> unlogin(Map<String, String> params) {
        return NetworkManager.getCommonClient()
                .create(ApiService.class)
                .unlogin(params)
                .compose(RxUtil.scheduleTnansform())
                .compose(RxUtil.handleResult());
    }

    //步数详情
    public static Flowable<StepDetailRes> stepDetail(Map<String, String> params) {
        return NetworkManager.getCommonClient()
                .create(ApiService.class)
                .stepDetail(params)
                .compose(RxUtil.scheduleTnansform())
                .compose(RxUtil.handleResult());
    }

    //心率详情
    public static Flowable<HrDetailRes> hrDetail(Map<String, String> params) {
        return NetworkManager.getCommonClient()
                .create(ApiService.class)
                .hrDetail(params)
                .compose(RxUtil.scheduleTnansform())
                .compose(RxUtil.handleResult());
    }

    //睡眠详情
    public static Flowable<SleepDetailRes> sleepDetail(Map<String, String> params) {
        return NetworkManager.getCommonClient()
                .create(ApiService.class)
                .sleepDetail(params)
                .compose(RxUtil.scheduleTnansform())
                .compose(RxUtil.handleResult());
    }

}
